package com.loveprogrammer.eternity.skill.support.skills;

import com.loveprogrammer.eternity.enums.AttackTypeEnum;
import com.loveprogrammer.eternity.model.Character;
import com.loveprogrammer.eternity.common.Tuple;
import com.loveprogrammer.eternity.model.attack.AttackResult;

import java.util.List;

/**
 * @version 1.0.0
 * @description: 被动技能 硬壳
 * @author: eric
 * @date: 2022-12-22 11:31
 **/
public class SkillHardShell extends PassiveSkill{

    private int reducePercent = 10;

    public SkillHardShell(int id, int baseInterval, int level, int order, int maxLevel, String name, String desc, int reducePercent) {
        super(id, baseInterval, level, order, maxLevel, name, desc);
        this.reducePercent = reducePercent;
    }

    protected SkillHardShell(int id, int baseInterval, int level, int order, int maxLevel, String name, String desc) {
        super(id, baseInterval, level, order, maxLevel, name, desc);
    }

    @Override
    public boolean checkLevelUp(int characterLevel) {
        // 每3级升一级
        if(characterLevel % 3 == 0){
            return true;
        }
        return false;
    }

    @Override
    protected Tuple<String, List<Character>> skillLaunch(Character character,
                                                         List<? extends Character> attack,
                                                         List<? extends Character> defences) {
        Tuple<String, List<Character>> tuple = new Tuple();
        AttackResult result = getAttackResult();
        if(!result.getAttackType().equals(AttackTypeEnum.NORMAL)){
            return tuple;
        }
        // 收到普通攻击，减少伤害
        double percents = (getLevel() + reducePercent) * 1.0 * getQuality().getRatio() / 100;
        int reduce = (int) (result.getHarm() * percents);
        tuple.setKey("被动技能" + getName() + "触发，减少伤害(" + reduce + "/" + result.getHarm() + ")");
        result.setHarm(result.getHarm() - reduce);
        return tuple;
    }

    @Override
    protected int computeHarm(Character character) {
        return 0;
    }

    @Override
    protected int computeSecondHarm(Character character) {
        return 0;
    }
}
